package com.winit.schedule.core.model;

import java.util.ArrayList;
import java.util.List;

import com.winit.schedule.core.repository.entity.TaskEntity;
import com.winit.schedule.core.repository.entity.TaskItemEntity;
import com.winit.schedule.core.task.ScheduleTaskDefine;

/**
 * 任务定义，提供关键信息给使用者
 * 
 * @author jianke.zhang 2015-3-13 上午9:39:18
 * @since 1.0
 */
public class AssignedTask extends TaskEntity {

    private ScheduleTaskDefine   taskDefine;

    /**
     * 任务项集合
     */
    private List<TaskItemEntity> taskItems          = new ArrayList<TaskItemEntity>();

    /**
     * 允许执行的开始时间(保留字段)
     */
    private long                 permitRunStartTime;

    /**
     * 允许执行的结束时间(保留字段)
     */
    private long                 permitRunEndTime;

    /**
     * 允许抓取任务的数量
     */
    private int                  allowTotalFetchNum = 1;

    /**
     * 本次抓取任务项的数量,大于0表示分发的可执行任务，小于0表示需要停止的TaskRunner数量
     * 此版本每次抓取的最大任务项为1
     */
    private int                  currentFetchNum    = 1;

    public List<TaskItemEntity> getTaskItems() {
        return taskItems;
    }

    public void setTaskItems(List<TaskItemEntity> taskItems) {
        this.taskItems = taskItems;
    }

    public long getPermitRunStartTime() {
        return permitRunStartTime;
    }

    public void setPermitRunStartTime(long permitRunStartTime) {
        this.permitRunStartTime = permitRunStartTime;
    }

    public long getPermitRunEndTime() {
        return permitRunEndTime;
    }

    public void setPermitRunEndTime(long permitRunEndTime) {
        this.permitRunEndTime = permitRunEndTime;
    }

    public ScheduleTaskDefine getTaskDefine() {
        return taskDefine;
    }

    public void setTaskDefine(ScheduleTaskDefine taskDefine) {
        this.taskDefine = taskDefine;
    }

    public int getAllowTotalFetchNum() {
        return allowTotalFetchNum;
    }

    public void setAllowTotalFetchNum(int allowTotalFetchNum) {
        this.allowTotalFetchNum = allowTotalFetchNum;
    }

    public int getCurrentFetchNum() {
        return currentFetchNum;
    }

    public void setCurrentFetchNum(int currentFetchNum) {
        this.currentFetchNum = currentFetchNum;
    }

    public String toString() {
        return this.getTaskId().getId();
    }

}
